package com.example.appsnight;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ProgramAdapter extends ArrayAdapter<ProgramActivity> {
	private final Context context;
	private final List<ProgramActivity> values;
	
	public ProgramAdapter(Context _context, List<ProgramActivity> _values) {
		super(_context,R.layout.program_item,_values);
		context = _context;
		values = _values;
	}
	
	//tots els components q usen adapters, contenen un getView
	//view grup = pare contenedor
	@Override
	public View getView(int position, View converView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
		View rowView = inflater.inflate(R.layout.program_item, parent, false);
		TextView timeLabel = (TextView)rowView.findViewById(R.id.programTimeTextView);
		TextView titleLabel = (TextView)rowView.findViewById(R.id.programTitleTextView);
//		TextView descrLabel = (TextView)rowView.findViewById(R.id.programDescrTextView);
		
		timeLabel.setText(values.get(position).getTime());
		titleLabel.setText(values.get(position).getTitle());
//		descr.setText(values.get(position).getCarrec());
		
		return rowView;
	}
}
